package com.shrct.businessprocess.budget;

import com.shrct.businessprocess.project.RCProjectMoney;
import edu.fudan.mylang.pf.BaseDataType;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.JoinColumn;
import org.eclipse.xtext.xbase.lib.DoubleExtensions;

public class RCBudgetDivision extends BaseDataType {
  public RCBudgetDivision() {
    super();
  }
  
  private String name;
  
  public String getName() {
    return this.name;
  }
  
  public RCBudgetDivision setName(final String name) {
    this.name = name;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "contractPrice_amount") ), @AttributeOverride(name = "workaround", column = @Column(name = "contractPrice_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "exchange", joinColumns = @JoinColumn(name = "contractPrice_exchange") ) )
  private RCProjectMoney contractPrice = com.shrct.businessprocess.project.RCProjectMoney.create();
  
  public RCProjectMoney getContractPrice() {
    return this.contractPrice;
  }
  
  public RCBudgetDivision setContractPrice(final RCProjectMoney contractPrice) {
    this.contractPrice = contractPrice;
    return this;			
    
  }
  
  private Double contractTaxRate;
  
  public Double getContractTaxRate() {
    return this.contractTaxRate;
  }
  
  public RCBudgetDivision setContractTaxRate(final Double contractTaxRate) {
    this.contractTaxRate = contractTaxRate;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "netPrice_amount") ), @AttributeOverride(name = "workaround", column = @Column(name = "netPrice_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "exchange", joinColumns = @JoinColumn(name = "netPrice_exchange") ) )
  private RCProjectMoney netPrice = com.shrct.businessprocess.project.RCProjectMoney.create();
  
  public RCProjectMoney getNetPrice() {
    return this.netPrice;
  }
  
  public RCBudgetDivision setNetPrice(final RCProjectMoney netPrice) {
    this.netPrice = netPrice;
    return this;			
    
  }
  
  private Double netTaxRate;
  
  public Double getNetTaxRate() {
    return this.netTaxRate;
  }
  
  public RCBudgetDivision setNetTaxRate(final Double netTaxRate) {
    this.netTaxRate = netTaxRate;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "actualCost_amount") ), @AttributeOverride(name = "workaround", column = @Column(name = "actualCost_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "exchange", joinColumns = @JoinColumn(name = "actualCost_exchange") ) )
  private RCProjectMoney actualCost = com.shrct.businessprocess.project.RCProjectMoney.create();
  
  public RCProjectMoney getActualCost() {
    return this.actualCost;
  }
  
  public RCBudgetDivision setActualCost(final RCProjectMoney actualCost) {
    this.actualCost = actualCost;
    return this;			
    
  }
  
  public Double getGrossProfit() {
    double _xifexpression = (double) 0;
    Double _amount = this.contractPrice.getAmount();
    boolean _equals = ((_amount).doubleValue() == 0);
    if (_equals) {
      return Double.valueOf(0d);
    } else {
      Double _hostAmount = this.contractPrice.toHostAmount();
      Double _hostAmount_1 = this.netPrice.toHostAmount();
      double _minus = DoubleExtensions.operator_minus(_hostAmount, _hostAmount_1);
      Double _hostAmount_2 = this.contractPrice.toHostAmount();
      double _divide = (_minus / (_hostAmount_2).doubleValue());
      _xifexpression = _divide;
    }
    return Double.valueOf(_xifexpression);
  }
  
  public static RCBudgetDivision create() {
    return new RCBudgetDivision();
    
    
  }
}
